﻿using System.Collections;
using System.Drawing;
using System.Windows.Forms;
using Narau.Required_interfaces;

namespace Narau.WindowsForms
{
    class Panel_WF : ReqIntf_Panel
    {
        private FlowLayoutPanel  m_FlowLayoutPanel;
        private Padding          m_margen_label;
        private Padding          m_margen_TextBox;
        private ArrayList        m_Label_List;
        private ArrayList        m_InputBox_List;

        //---------------
        // Constructor
        //---------------
        public Panel_WF(FlowLayoutPanel panel)
        {
            //LabelText_description  = label_text;
            m_FlowLayoutPanel = panel;

            m_margen_label = new Padding();
            m_margen_label.Left = 0;
            m_margen_label.Right = 0;
            m_margen_label.Top = 4;
            m_margen_label.Bottom = 0;

            m_margen_TextBox = new Padding();
            m_margen_TextBox.Left = 0;
            m_margen_TextBox.Right = 0;
            m_margen_TextBox.Top = 0;
            m_margen_TextBox.Bottom = 0;

            m_Label_List = new ArrayList();
            m_InputBox_List = new ArrayList();
        }

        //-----------------------------------------------------
        //  Implementación del interfaz: ReqIntf_Panel 
        //-----------------------------------------------------
        #region ReqIntf_Panel Members

            public void Clear()
            {
                if (m_FlowLayoutPanel != null)
                {
                    m_FlowLayoutPanel.Controls.Clear();
                }
            }

            public void AddText(string txt, ENR_FontType font_type, bool bBorder)
            {
                Label new_label = new Label();

                switch (font_type)
                {
                    case ENR_FontType.NFT_NIHONGO:
                        new_label.Font = GlobalFonts.m_nihongo_font;
                        break;
                    case ENR_FontType.NFT_STANDARD:
                        new_label.Font = GlobalFonts.m_standard_font;
                        break;
                }
                
                new_label.TextAlign = ContentAlignment.BottomCenter;
                new_label.Margin = m_margen_label;
                new_label.AutoSize = true;
                new_label.Text = txt;
                new_label.BorderStyle = bBorder? BorderStyle.FixedSingle : BorderStyle.None;

                m_FlowLayoutPanel.Controls.Add(new_label);
            }

            public ReqIntf_Label AddLabel()
            {
                Label new_label = new Label();

                new_label.Font        = GlobalFonts.m_standard_font;
                new_label.BorderStyle = BorderStyle.None;
                new_label.TextAlign   = ContentAlignment.MiddleLeft;
                new_label.Margin      = m_margen_label;
                new_label.AutoSize    = true;
                new_label.Text        = "";

                m_FlowLayoutPanel.Controls.Add(new_label);

                Label_WF new_label_WF = new Label_WF(new_label);
                m_Label_List.Add(new_label_WF);

                return new_label_WF;
            }

            public ReqIntf_InputBox AddInputBox(int iNumChars)
            {
                TextBox new_TextBox = new TextBox();

                new_TextBox.BorderStyle = BorderStyle.FixedSingle;
                new_TextBox.Font        = GlobalFonts.m_nihongo_font;
                new_TextBox.Width       = (int)(GlobalFonts.m_nihongo_font.SizeInPoints * (float)(iNumChars + 2));
                //new_TextBox.Height = 4;
                new_TextBox.Margin      = m_margen_TextBox;
                new_TextBox.TextAlign   = HorizontalAlignment.Left;

                m_FlowLayoutPanel.Controls.Add(new_TextBox);

                InputBox_WF new_InputBox_WF = new InputBox_WF(new_TextBox);
                m_InputBox_List.Add(new_InputBox_WF);

                return new_InputBox_WF;
            }

        #endregion
    }
}
